﻿using WorkflowCore.Interface;
using WorkflowCore.Models;

namespace Service.CertWorkFlow.Steps
{
    public class GetCert : StepBodyAsync
    {
        public override async Task<ExecutionResult> RunAsync(IStepExecutionContext context)
        {
            var data = context.Workflow.Data as WorkflowData;
            data.Action?.Invoke("正在获取证书");
            var res = await data.CertService.GetCert();
            data.Action?.Invoke(res.Message);
            if (res.Successed)
            {
                data.CertResult = res;
            }
            else
            {
                throw new Exception(res.Message);
            }
            return ExecutionResult.Next();
        }
    }
}
